import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export const useCounterStore = defineStore('counter', () => {
  const count = ref(0)
  const doubleCount = computed(() => count.value * 2)
  function increment() {
    count.value++
  }

  return { count, doubleCount, increment }
})

// 登陆拿到的数据
export const useAdmin = defineStore('userAdmin', {
  state: () => ({
    userData: {
      currentMobile: null,
      existingMobile: null,
      multiLoginId: null,
      newComerPackageUrl: null,
      newMemberTicketStatus: false,
      page: '',
      token: '',
      type: null,
      user: {
        account: {
          storedValueCash: 0,
          storedValueGive: 0
        },
        aliInfo: {
          certNo: null,
          openId: null,
          realName: null
        },
        aliRpRecord: null,
        appleInfo: null,
        //头像
        avatar: '',
        birthday: null,
        city: null,
        flags: null,
        memberCardNo: null,
        //手机号
        mobile: '',
        // 用户名
        nickname: '',
        openCardInfo: {
          certNo: null,
          mobile: null,
          realName: null
        },
        province: null,
        qqInfo: null,
        realName: null,
        sex: null,
        //用户id
        userId: '',
        wechatInfo: null
      },
      verifyStatus: null
    }

  }),
  actions: {
    changeState(params: object) {
      console.log('接收到的参数===>', params)
      this.userData = params
    }
  },

})

// 订单信息
export const useOrder = defineStore('userOdmin', {
  state: () => ({
    OrderList:[]
  }),
  actions: {
    changeState(params: object) {
      this.OrderList = params
      console.log('接收到的参数===>', params)
    }
  }
})

// 购物车
export const shopList = defineStore('usershop',{
  state: () => ({
    UserShopList:[]
  }),
  actions: {
    changeState(params: object) {
      console.log('购物车列表===>', params)
      this.UserShopList = params
    }
  },
})